package com.xunfang.portal.controller;

import com.xunfang.portal.model.entity.BookType;
import com.xunfang.portal.service.BookTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 书籍分类
 *      ResponseEntity
 *         和我们之前封装的 data 类似
 *         status  状态码
 *         body    内容
 */
@RestController
@RequestMapping("/bookType")
@Tag(name = "书籍分类")    //swagger 告诉别人这个类是做什么的
public class BookTypeController {

    @Autowired
    private BookTypeService bookTypeService;

    /**
     * 查询所有的书籍分类
     */
    @GetMapping("/findAll")
    @Operation(summary = "查询分类的 type")
    public ResponseEntity<List<BookType>> findAll() {
        List<BookType> types = bookTypeService.findAll();
        return ResponseEntity.ok(types);
    }

}